#include <math.h>
#include "statFunctions.h"

double statFunctions_mean(LSE* arrList)
{
	SINT32 arrSize = lse_size(arrList);
	FLOAT64 mean = 0;
	UINT32 i = 0;

	for(i = 0; i < arrSize ; i++)
		mean += lse_get(arrList,i);

	return mean /= (FLOAT64)arrSize;
}

double statFunctions_stdDev(LSE* arrList, FLOAT64 mean)
{
	SINT32 arrSize = lse_size(arrList);
	UINT32 i = 0;
	FLOAT64 stdDev = 0, tmp;

	for(i = 0; i < arrSize ; i++){
		tmp = lse_get(arrList,i) - mean;
		stdDev += tmp*tmp;
	}

	stdDev /= (FLOAT64)arrSize;
	return sqrt(stdDev);
}
